package com.info.zhiduoduo.repository.mapper.maker;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.info.zhiduoduo.repository.dto.maker.MakerBankcardDto;
import com.info.zhiduoduo.repository.entity.maker.MakerBankcard;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 * 创客银行卡(信用卡) Mapper 接口
 * </p>
 *
 * @author bob
 * @since 2018-12-23
 */
public interface MakerBankcardMapper extends BaseMapper<MakerBankcard> {

	@Select("select id,userid,payername,bankname,open_acct_bank_name,telephone,acctno,province,city,idno,state,createtime,alipay_account,payment_account_status " +
			"from zdd_maker_bankcard " +
			"where userid = #{userid} " +
			"and state = 1 and accttype = 1 " +
			"limit 1")
	MakerBankcardDto getUserValidBankcard(@Param("userid") int userid);

	@Select(" select * from zdd_maker_bankcard where state = 1 and userid = #{userid} and accttype = 1 order by createtime desc limit 1 ")
	MakerBankcard getDefaultBankcard(@Param("userid") int userid);

	@Update(" update zdd_maker_bankcard " +
			" set open_acct_bank_name = #{openAcctBankName} " +
			" where userid = #{userid} " +
			" and state = 1 and accttype = 1 ")
	boolean updateOpenAcctBankName(@Param("openAcctBankName") String openAcctBankName, @Param("userid") int userid);

}
